package br.com.biovida.persistencia.daos;

import java.io.Serializable;
import java.math.BigInteger;
import java.util.List;
import java.util.Map;

import org.hibernate.criterion.DetachedCriteria;
import org.hibernate.criterion.MatchMode;
import org.hibernate.criterion.Order;
import org.hibernate.stat.Statistics;


public interface IDAO<T> {

	@SuppressWarnings("rawtypes")
	public Class recuperarPersisteClass() throws Exception;

	public void salvar(T objeto) throws Exception;
	
	public void persistir(T objeto, CrudOperationEnum crudOperationEnum) throws Exception;

	public void salvarOuAtualizar(T objeto) throws Exception;

	public T carregarLoad(Integer id) throws Exception;
	
	public T carregarGet(Integer id) throws Exception;
	
	public T carregarLoad(Serializable id) throws Exception;

	public T carregarGet(Serializable id) throws Exception;	
	
	public void atualizar(T objeto) throws Exception;

	public void remover(T objeto) throws Exception;

	public T buscarEntidadePorExemplo(final T exemplo) throws Exception;
	
	public List<T> buscarPorNamedQuery(String namedQuery) throws Exception;
	
	public List<T> buscarPorNamedQuery(String namedQuery,Map<String, Object> parametros) throws Exception;
	
	public T buscarEntidadePorNamedQueryWithMaxResult(String namedQuery, Map<String, Object> parametros,Integer maxResult) throws Exception;
	
	public T obterPorNamedQuery(String namedQuery, Map<String, Object> parametros) throws Exception;
	
	public List<T> buscarPorNativeQuery(String sql, Map<String, Object> parametros) throws Exception;
	
	public void executarNativeQuery(String sql, Map<String, Object> parametros) throws Exception;
	
	public void executarQuery(String sql, Map<String,Object> parametros) throws Exception;
	
	public List<T> listarTodos() throws Exception;
	
	public List<T> listarPorQuery(String sql, Map<String, Object> parametros) throws Exception;

	public List<T> listarPorExemplo(final T exemplo) throws Exception;

	public List<T> listarPorExemplo(T objeto, MatchMode matchMode) throws Exception;	
	
	public void  executarNamedQuery(String namedQuery, Map<String, Object> parametros) throws Exception;	
	
	public Object executarCriteria(DetachedCriteria detachedCriteria) throws Exception;
	
	public List<T> listarPorCriteria(DetachedCriteria detachedCriteria, Order...order) throws Exception;
	
	public T buscarPorCriteria(DetachedCriteria detachedCriteria) throws Exception;

	public T buscarEntidadePorNamedQuery(String namedQuery, Map<String, Object> parametros) throws Exception;

	void salvarEmLote(List<T> pLista) throws Exception;
	
	public Statistics getStatistics() throws Exception;
	
	public List<T> listarPorCriteriaDemanda(DetachedCriteria detachedCriteria, Integer startPage, Integer maxPage) throws Exception;
	
	public Integer count(DetachedCriteria detachedCriteria) throws Exception;
	
	public BigInteger countNativeQuery(String sql) throws Exception;

	void mergeEmLote(List<T> pLista) throws Exception;

}